package jdbc.day2.demo3_primaryKey;

import tmp.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class A {
    public static void main(String[] args)throws Exception {
        Connection con= DBUtil.getConnection();
        Statement st=con.createStatement();//rowNum
        int rs=st.executeUpdate("insert into stu(sname) values('c1'),('c2')",Statement.RETURN_GENERATED_KEYS);
        if(rs>0){
            System.out.println("添加成功");
        }
        ResultSet res=st.getGeneratedKeys();
        while (res.next()){
            System.out.println(res.getInt(1));
        }
        res.close();
        st.close();
        con.close();
    }
}
